package com.example.usermanager.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 系统的配置文件
 */
@Configuration
public class ApplicationConfig implements WebMvcConfigurer {
    @Autowired
    private LoginIntercept loginIntercept;  //注入拦截器

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginIntercept).
                addPathPatterns("/**").  //拦截所有的文件
                excludePathPatterns("/login").  //排除登录操作
                excludePathPatterns("/css/**").  //排除前端的界面
                excludePathPatterns("/fonts/**").
                excludePathPatterns("/images/**").
                excludePathPatterns("/js/**").
                excludePathPatterns("/login.html");
    }
}
